package GUILayer;

import java.util.ArrayList;

import javax.swing.table.AbstractTableModel;

import ControlLayer.Ctr;
import ModelLayer.Product;


@SuppressWarnings("serial")
public class ProductTable extends AbstractTableModel {

private static final String[] columnNames = { "ID", "Name", "Price", "Origin", "Stock", "Supplier ID","Clothing ID","Equipment","Loan" };
//private Model.EmployeeContainer empcont;
private ArrayList<Product> emp;
private Ctr ctr = new ControlLayer.Ctr();
private ArrayList<Product> customerList;
public ProductTable(){
	emp = new ArrayList<Product>();
	
	customerList = ctr.findAllProduct(); 
	for(ModelLayer.Product e : customerList )
	{emp.add(e);

}
}

@Override
public int getColumnCount() {
    // TODO Auto-generated method stub
    return columnNames.length;
}

@Override
public int getRowCount() {
    return emp.size();
}

@Override
public String getColumnName(int column) {
    return columnNames[column];
}

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    switch (columnIndex) {
    case 0:
        return emp.get(rowIndex).getpID();
    case 1:
        return emp.get(rowIndex).getName();
    case 2:
        return emp.get(rowIndex).getPrice();
    case 3:
        return emp.get(rowIndex).getOcountry();
    case 4:
    	return emp.get(rowIndex).getStock();
    case 5:
    	return emp.get(rowIndex).getSuID();
    case 6:
    	return emp.get(rowIndex).getClID();
    case 7:
    	return emp.get(rowIndex).getEqID();
    case 8:
    	return emp.get(rowIndex).getlID();
    }
    return null;
} 
}
